﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sispe.BussinesLogic;
using Sispe.Entities;
using Microsoft.Practices.Unity;

namespace Sispe.UI
{
    public partial class FrmInputTareoBorrador : Form
    {
        [Dependency]
        public ITareoBL tareoBL { get; set; }

        public FrmInputTareoBorrador()
        {
            InitializeComponent();
            this.BuildUp();
        }

        public string dni;
        public int idTareo;

        public void Editar()
        {
            tAREO_BORRADORBindingSource.DataSource = tareoBL.GetAllFromTareoBorradorById(idTareo);
            tAREO_BORRADORBindingSource.ResetBindings(true);
        }

        private void FrmInputTareoBorrador_Load(object sender, EventArgs e)
        {

        }

        private void btnGuardar_Click(object sender, EventArgs e)
        {
            var _current = tAREO_BORRADORBindingSource.Current as TAREO_BORRADOR;
            var msg = "ERROR!";

            try
            {
                tareoBL.UpdateTareoBorradorSQL(_current, dni);
                MessageBox.Show("Registro correcto!", "OK!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                msg = ex.Message;
                MessageBox.Show(msg, "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
